-- MainMapEffects
-- create by zouyb
-- 主界面特效表现相关

-- 判断特效节点是否在地图的可见区域
function isEffectNodeVisible(node)
    -- 转成世界坐标，如果在屏幕区域外，则为不可见
    local worldPos = node:convertToWorldSpaceAR(cc.p(0, 0));

    -- 屏幕大小
    local width = AlignM.frameSize.width;
    local height = AlignM.frameSize.height;

    if worldPos.x > width or worldPos.x < 0
       or worldPos.y > height or worldPos.y < 0 then
       return false;
    end

    return true;
end

-- 判断特效节点是否在地图的可见区域
function isEffectNodeVisible2(node)
    -- 转成世界坐标，如果在屏幕区域外，则为不可见
    local worldPos = node:convertToWorldSpaceAR(cc.p(0, 0));

    -- 屏幕大小
    local width = AlignM.frameSize.width;
    local height = AlignM.frameSize.height;

    if worldPos.x > width or worldPos.x < 0
        or worldPos.y > height * 1.5 or worldPos.y < - 0.5 * height then
        return false;
    end

    return true;
end

-- 炼金坊冒烟特效
function playBlacksmithEffect1(parentNode)
    playEffect(parentNode, 2000, 0, 0);
end

-- 炼金坊放光特效
function playBlacksmithEffect2(parentNode)
    playEffect(parentNode, 2001, 0, 0);
end

-- 炼金坊粒子特效
function playBlacksmithEffect3(parentNode)
    playEffect(parentNode, 2002, 0, 0);
end

-- 英雄之村旗子特效
function playFlagEffect(parentNode)
    playEffect(parentNode, 2006, 0, 0);
end

-- 骷髅岛特效
function playSkullIslandEffect(parentNode)
    playEffect(parentNode, 2007, 0, 0);
end

-- 圣者之塔
function playSageTowerEffect(parentNode)
    playEffect(parentNode, 2008, 0, 0);
end

-- 海盗港湾特效
function playPiratesHarbourEffect1(parentNode)
    playEffect(parentNode, 2009, 0, 0);
end

-- 海盗港湾旗子特效
function playPiratesHarbourEffect2(parentNode)
    playEffect(parentNode, 2010, 0, 0);
end

-- 绵羊特效1
function playSheepEffect1(parentNode)
    playEffect(parentNode, 2011, 0, 0);
end

-- 绵羊特效2
function playSheepEffect2(parentNode)
    playEffect(parentNode, 2012, 0, 0);
end

-- 雪特效
function playSnowEffect(parentNode)
   playEffect(parentNode, 2013, 0, 0);
end

-- 蒸汽特效
function playSteamEffect(parentNode)
    playEffect(parentNode, 2014, 0, 0);
end

-- 海浪特效
function playWavesEffect(parentNode)
    playEffect(parentNode, 2015, 0, 0);
end

-- 低语之森蒸汽特效
function playWhisperForestEffect2(parentNode)
    playEffect(parentNode, 2016, 0, 0);
end

-- 低语之森彩虹特效
function playWhisperForestEffect3(parentNode)
    playEffect(parentNode, 2017, 0, 0);
end

-- 熔岩特效
function playLavaEffect(parentNode)
    playEffect(parentNode, 2018, 0, 0);
end

-- 传送门特效
function playPortalEffect(parentNode)
    playEffect(parentNode, 2019, 0, 0);
end

-- 蝙蝠飞出特效
function playBatEffect(parentNode)
    -- 间隔5-8秒
    local function play()
        if UIMgr.getCurrentScene().mainMap and UIMgr.getCurrentScene().mainMap:isVisible() then
            playEffect(parentNode, 2020, 0, 0);
        end

        performWithDelay(parentNode, play, 8);
    end

    play();
end

-- 世界树特效
function playWorldTreeEffect(parentNode)
    playEffect(parentNode, 2022, 0, 0);
end

-- 混沌深渊特效
function playAbyssEffect(parentNode)
    playEffect(parentNode, 2023, 0, 0);
end

-- 骷髅岛旁小岛特效
function playIslandEffect(parentNode)
    playEffect(parentNode, 2024, 0, 0);
end

-- 佣兵营地发光
function playCampEffect1(parentNode)
    playEffect(parentNode, 2025, 0, 0);
end

-- 佣兵营地粒子
function playCampEffect2(parentNode)
    playEffect(parentNode, 2026, 0, 0);
end
